package com.zh.note.demo.javaSE;

/**
 * @Author: zhanghuan
 * @date: 2023/8/22 09:19
 * @description: create it
 */
public class StringBuilderDemo {
    public static void main(String[] args) {
//        String str = "Hello, world";
//        StringBuilder sb = new StringBuilder(str);
//        //在索引1处插入hi字符串
//        // sb.insert(1, "hi");
//        //在索引1处往后查找lo首次出现的下标
//        int lo = sb.indexOf("lo", 1);
//        //在索引1处往前查找lo首次出现的下标
//        int lo1 = sb.lastIndexOf("lo", 1); // -1 没有找到
//        String temp = "lo";
//        //把1-2的字符替换成temp
//        sb.replace(1, 1 + temp.length(), temp);
//        System.out.println(sb);


        StringBuilder sb = new StringBuilder(10);
        sb.append("1234");
        System.out.println(sb.length());
        System.out.println(sb.capacity());
    }
}
